<?php

class remarksAction extends Action
{

	//remarks表操作
    public function remarksadd(){
    	$this->display();

    }
    public function remarksaddsave(){
    	$remarks=new remarksModel();
    	if(!$remarks->create()){
    		$this->error($remarks->getError());
    	}else{
    	$id=$remarks->add();
    	$this->assign("jumpUrl",U("remarks/remarkscontent",array('id'=>$id)));
    	$this->success("添加成功");
    	}
    }
    public function remarkslist(){
    	$remarks=new remarksModel();
        import("ORG.Util.Page");
        $pagsize=15;
        $totalnum=$remarks->count();
        $list=$remarks->page($_GET['p'])->order('id desc')->limit()->select();
        $this->assign("list",$list);
        $page=new Page($totalnum,$pagsize);
        $page->rollPage=$pagsize;
    	$page->setConfig("prev","上一页");
    	$page->setConfig("next","下一页");
    	$page->setConfig("first","首页");
    	$page->setConfig("last","末页");
    	$page->setConfig("theme","共%totalRow%%header%条数据 %nowPage%/%totalPage%页  %first% %upPage%   %linkPage%  %downPage% %end%");
    	$pageshow=$page->show();
    	$this->assign("pageshow",$pageshow);
    	$this->display();
    }
    public function remarksadmin(){
    	$remarks=new remarksModel();
        import("ORG.Util.Page");
        $totalnum=$remarks->count();
        $list=$remarks->page($_GET['p'])->limit(10)->select();
        $this->assign("list",$list);
        $page=new Page($totalnum,10);
        $page->rollPage=10;
    	$page->setConfig("prev","上一页");
    	$page->setConfig("next","下一页");
    	$page->setConfig("first","首页");
    	$page->setConfig("last","末页");
    	$page->setConfig("theme","共%totalRow%%header%条数据 %nowPage%/%totalPage%页  %first% %upPage%   %linkPage%  %downPage% %end%");
    	$pageshow=$page->show();
    	$this->assign("pageshow",$pageshow);
    	$this->display();
    }
    public function remarksupdate(){
    	$remarks=new remarksModel();
    	$data=$remarks->where("id='{$_GET['id']}'")->find();
    	$this->assign("data",$data);
    	$this->display();
    }
    public function remarksupdatesave(){
    	$remarks=new remarksModel();
    	if(!$remarks->create()){
    		$this->error($remarks->getError());
    	}else{
    		$remarks->save();
    		$this->success("修改成功");
    	}
    }
    public function remarkscontent(){
    	$remarks=new remarksModel();
    	$data=$remarks->where("id='{$_GET['id']}'")->find();
    	$this->assign("data",$data);
    	$this->display();
    }

    public function delete()
    {
        $remarks = M("remarks");
        if (!$remarks->delete($_GET['id']))
        {
            $this->error("删除失败");
        } else
        {
            $this->success("删除成功");
        }
    }
    
    public function _empty(){
   //空操作
    $this->error("您访问的页面不存在！");
    }

}
?>